package mest.service.hws.impl;

import com.alibaba.fastjson.JSON;
import mest.dao.hws.plan_productjob_workfinishMapper;
import mest.entity.plan_productjob_purchase_record;
import mest.entity.plan_productjob_workfinish;
import mest.entity.plan_productjob_workfinish_record;
import mest.service.hws.plan_productjob_workfinishService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/*
 * 数据流完工表
 * */
@Service
public class plan_productjob_workfinishServiceImpl implements plan_productjob_workfinishService {

    @Resource
    private plan_productjob_workfinishMapper plan_productjob_workfinishMapper;

    /*
     * 新增
     * */
    @Override
    public List<Map<String,Object>> insert(List<Map<String,Object>> record) {
        /*/insertModel /delModel /updateByone*/
        System.out.println("进入增删改方法");
        Map<String, Object> map = new HashMap<String, Object>();
        try {
            plan_productjob_workfinishMapper.insert(record);
            System.out.println("返回的数据数组"+record);
        } catch (Exception e) {
            map.put("code", 1);
            map.put("msg", "操作失败");
            e.toString();
        }
        return record;
    }

    /*
    * 根据pwid查询关联内容表
    * */
    @Override
    public String selectAll(Map<String, Object> map1) {
        /* selectById  selectAll  */
        System.out.println("进入查询");
        Map<String,Object> map = new HashMap<String,Object>();
        try {
            map1.put("page",(Integer.parseInt(map1.get("page").toString())-1)*Integer.parseInt(map1.get("limit").toString()));
            List<Map<String, Object>> maps  = plan_productjob_workfinishMapper.selectPrimary(map1);
                map.put("code",0);
                map.put("msg","查询成功");
                map.put("count",plan_productjob_workfinishMapper.selectcount(map1));
                map.put("data",maps);
        }catch (Exception e){
                System.out.println(e.toString());
                map.put("code",1);
                map.put("msg","查询失败");
                map.put("errmsg",e.toString());
        }
        return JSON.toJSONString(map);
    }

    @Override
    public int updateByone(List<Map<String, Object>> map) {
        return plan_productjob_workfinishMapper.updateByone(map);
    }
}
